<html>
<head>
<link rel="stylesheet" type="text/css" href="./styles1/tabber.css">
<script type="text/javascript" src="./js/tabber.js"></script>

<?php
    include 'header.php';
  ?>
<body>

<?php
$phylum=$_GET['arg1'];
echo "Phylum is: $phylum<br>";
$period=$_GET['arg2'];
echo "Period is: $period<br>";

$username = "fossilplot";
$password = "fossilplot";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
//select a database to work with
$selected = mysql_select_db("fossilplot",$dbhandle)
  or die("Could not select examples");

$pd_short=mysql_query("select pd_short from period where pd='$period'") or die ("error selecting from stgintv!!");
while($row_pd_short=mysql_fetch_array($pd_short)){
    $short=$row_pd_short{'pd_short'};
    //echo "short is ".$row_pd_short{'pd_short'}."<br>";

}


if($short=="Pg"){
    $genera=mysql_query("select genus_name, phylum_name, class_name, order_name, fad_period,fad_date,lad_period, lad_date from genus where phylum_name='$phylum' and ((fad_period='T' and fad_date >='23.03') or (lad_period='T' and lad_date >='23.03'))") or die ("error selecting from period!!");
}
else if($short =="Ng"){
        $genera=mysql_query("select genus_name, phylum_name, class_name, order_name, fad_period, fad_date,lad_period,lad_date from genus where phylum_name='$phylum' and ((fad_period='T' and fad_date <'23.03') or (lad_period='T' and lad_date <'23.03'))") or die ("error selecting from period!!");

}
else if($short == "VC"){
        //echo "it is true!";
        $genera=mysql_query("select genus_name,phylum_name, class_name, order_name, fad_period, fad_date,lad_period,lad_date from genus where phylum_name='$phylum' and (fad_period='V' or fad_period ='Cm' or lad_period='V' or lad_period ='Cm')") or die ("error selecting from period!!");

}

else{
 $genera=mysql_query("select genus_name,phylum_name, class_name, order_name, fad_period, fad_date, lad_period, lad_date from genus where (fad_period='$short' or lad_period='$short') and phylum_name='$phylum'") or die ("error selecting from stgintv!!");
}

$page= (mysql_num_rows($genera)/150);
 echo "<center>";  
  
echo "<div class=\"tabber\" id=\"tab1-1\">";
for($j=0;$j<$page; $j++){ 
  
	echo "<div class=\"tabbertab\" title=\"$j\">";
		
		echo "<table align=center border=0>";
			echo "<tr align=left>";
				echo "<td><font size=2>Genus</font></td><td><font size=2>Phylum</font></td><td><font size=2>Class</font></td><td><font size=2>Order</font></td><td><font size=2>Fad_Std</font></td><td><font size=2>Fad_Date</font></td><td><font size=2>Lad_Std</font></td><td><font size=2>Fad_Date</font></td>";
			echo "</tr>";
		$k=0;
 
		while ($k<150 && $row = mysql_fetch_array($genera)) {
			print "<tr><td><font size=2>".$row{'genus_name'}."</font></td><td><font size=2>".$row{'phylum_name'}."</font></td><td><font size=2>".$row{'class_name'}."</font></td><td><font size=2>".$row{'order_name'}."</font></td><td><font size=2>".$row{'fad_period'}."</font></td><td><font size=2>".$row{'fad_date'}."</font></td><td><font size=2>".$row{'lad_period'}."</font></td><td><font size=2>".$row{'lad_date'}."</font></td></tr>";
			$k++;
		}
		
		echo "</table>";
	echo "</div>";
}

echo "</div>"; 
 
echo "</center>";


?>
<?php include 'footer.php';?>

</body>
</html>